#include "RealICompare.h"

RealICompare compare;

HRESULT STDMETHODCALLTYPE RealICompare::QueryInterface(REFIID riid, void **ppv)
{
    if (IsEqualIID(riid, IID_IUnknown) ||
        IsEqualIID(riid, DIID_ICompare))
    {
        *ppv = this;
        return S_OK;
    }

    *ppv = NULL;
    return E_NOINTERFACE;
}

ULONG STDMETHODCALLTYPE RealICompare::AddRef()
{
    return 1;
}

ULONG STDMETHODCALLTYPE RealICompare::Release()
{
    return 1;
}

LONG STDMETHODCALLTYPE RealICompare::Compare(const void *elem1, const void *elem2)
{
    if (*((DWORD *)elem1) == *((DWORD *)elem2)) return 0;
    if (*((DWORD *)elem1) < *((DWORD *)elem2)) return -1;
    return 1;
}
